<?php
function fetchAll2($sqlQuery, $value = NULL) {
        $_return = array();
        $_ret = sql_query($sqlQuery);
        while($_res = sql_fetch_array($_ret)) {
                $_temp = NULL; 
                if($_res['v'] === '' || $_res['v'] === NULL) {
                    break; // NULL값 빼내기
                }
                if($_res['v'] == $value) {
                    $_temp = 'true'; 
                }
                if(!isset($_res['n'])) {
                    $_res['n'] = $_res['v']; 
                } else {
                    $_temp = NULL; 
                    if($_res['n'] == $value) {
                        $_temp = 'true'; 
                    }
                }
                $_return[] = array($_res['n'], $_res['v'], $_temp);
        }
        return $_return;
}

function fileDelete($_filename, $_dbName, $_dbField, $_articleNum, $targetDir) {
    $_delQuery = "SELECT $_dbField as v FROM $_dbName WHERE `no` = '$_articleNum'"; 
    $res = sql_fetch($_delQuery);
    if($res['v'] == $_filename) {
        $res = @unlink($targetDir.$_filename);
        /*if(!$res) {
            alert("오류 : 파일삭제 오류".$targetDir.$_filename);
        }*/
    } else {
        alert("오류 : 잘못된 접근입니다.");
    }
}


function _makeOptionList($arrayString, $indexKey=NULL) {
    $_temp = NULL; 
    foreach($arrayString as $key => $value) {
        $selected = ($key == $indexKey) ? "selected=selected": NULL;
        $_temp.= "<option value=\"$key\" $selected>$value</option>";
    }
    return $_temp;
}

function _makeSqlWhere($_sqlWhere, $key, $value, $isLike = FALSE) {
    $equal = '=';
    if($isLike) {
        $equal = ' LIKE '; 
    }
    if($_sqlWhere && $key && $value) {
        return $_sqlWhere." AND $key $equal'$value'"; 
    } else if($key && $value) {
        return " WHERE $key $equal'$value'"; 
    }
    return $_sqlWhere; 
}

function makelink($notkey) {
    global $_GET;
    $link = '&';
    foreach($_GET as $key => $value) {
        if(!in_array($key, $notkey)) {
            $link.= $key.'='.urlencode($value).'&';
        }
    }
    return $link;
}
